/**
 * @class MilkywayGUI
 * The main singleton class to handle the framework.
 *
 * @singleton
 */
MilkywayGUI = ({
	events: new Hash(),
	/**
	 * The version of the framework
	 * @type String
	 */
	version:	'0.2a',

	/**
	 * Alter for window.addEvent() method.
	 *
	 * @param {Function} eventHandler This function will call when windows'
	 * DOM created.
	 * @return void
	 */
	start: function(eventHandler) {
		window.addEvent('domready', eventHandler);
	},

	registerEventHandler: function() {
		window.addEvent('keydown', function(event) {
			if (MilkywayGUI.events.has(event.key)) MilkywayGUI.events.get(event.key).handler.run(event);
		});
	},

	/**
	 * Register event handler for the Milkyway-GUI.
	 *
	 * @param {Sting} key The key for pressing. You feel free to set Ctrl+Enter,
	 * or other combinations also.
	 * @param {String} name The name of the action.
	 * @param {Function} handler The event handler function.
	 * @param {Boolean} [force] If key handler registered, then force decide
	 * whether it will overwritten or not.
	 * @return void
	 */
	addEventHandler: function(key, name, handler) {
		if (arguments[3] == true) MilkywayGUI.events.set(key.toLowerCase(), {
			'name':		name,
			'handler':	handler
		});
		else MilkywayGUI.events.include(key.toLowerCase(), {
			'name':		name,
			'handler':	handler
		});
	},

	getEventKeys: function() {
		return this.events.getKeys();
	}
});
/*
var Asset = {
	javascript: function(f, d) {
		d = $extend({
			onload:$empty,
			document:document,
			check:$lambda(true)
		},d);
		if(d.onLoad){
			d.onload=d.onLoad;
		}
		var b=new Element("script",{src:f,type:"text/javascript"});
	}
	*/

MilkywayGUI.registerEventHandler();